{extend name="main/main" /}
{block name="main"}
<!--零售单-->
<link rel="stylesheet" href="/skin/css/public/ui.jqgrid.css" type="text/css" media="all" />
<link rel="stylesheet" href="/skin/css/public/jquery-ui.min.css" type="text/css" media="all" />
<link rel="stylesheet" href="/skin/css/main/public_form.css" type="text/css" media="all" />
<link rel="stylesheet" href="/skin/css/public/zTreeStyle.css" type="text/css" media="all" />
<link rel="stylesheet" href="/skin/css/public/select2.css" type="text/css" media="all" />
<link rel="stylesheet" href="/skin/css/main/cashierinfo.css" type="text/css" media="all" />
<div class="operation">
    <div class="form_info layui-form layui-form-pane">
        <div class="layui-form-item" style="margin-left: 0;">
            <label class="layui-form-label">单据日期</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" id="time" placeholder="单据日期" value="{$class.time}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单据编号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" id="number" placeholder="单据编号" value="{$class.number}">
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
    <div class="set_btn">
            {empty name="Think.get.id"}
                <button class="layui-btn layui-btn-normal" onclick="save(this);">提交单据</button>
            {else/}
                {notempty name="auth_info"}
                    {empty name="class.type.ape"}
                        {if condition="(check_root('cashier_edit'))"}
                            <button class="layui-btn layui-btn-normal" onclick="save(this,'{$Think.get.id}');">保存单据</button>
                        {/if}
                        {if condition="(check_root('cashier_auditing'))"}
                            <button class="layui-btn layui-btn-primary" onclick="auditing('{$Think.get.id}',true);">审核单据</button>
                        {/if}    
                    {else/}
                        {if condition="(check_root('cashier_auditing'))"}
                            <button class="layui-btn layui-btn-primary" onclick="auditing('{$Think.get.id}',false);">反审核单据</button>
                        {/if}
                    {/empty}
                {/notempty}
            {/empty}
        <button class="layui-btn" onclick="ape_re();">重新载入</button>
    </div>
</div>
<hr />
<div class="table_info">
    <table id="table"></table>
</div>
<div class="table_more layui-form layui-form-pane">
    <table class="more_info">
        <tr>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">单据金额</label>
                    <div class="layui-input-block">
                        <input type="text" id="total" placeholder="单据金额" class="layui-input" disabled="disabled" value="{$class.total}">
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">优惠金额</label>
                    <div class="layui-input-block">
                        <input type="text" id="discount" placeholder="请输入优惠金额" class="layui-input" value="{$class.discount}" onBlur="cal_money();" >
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">实收金额</label>
                    <div class="layui-input-block">
                        <input type="text" id="money" placeholder="请输入实收金额" class="layui-input" value="{$class.money}" >
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">客户</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="customer" placeholder="请点击选择" readonly="true" onclick="set_customer(this)" ape=''>
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">制单人</label>
                    <div class="layui-input-block">
                		<select id="user" class="layui-input" lay-search>
                		    <option value="">请选择制单人</option>
                		    {volist name="user" id="user_vo"}
                                <option value="{$user_vo.id}">{$user_vo.name}</option>
                            {/volist}
                		</select>
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">本次积分</label>
                    <div class="layui-input-block">
                        <input type="text" id="integral" placeholder="请输入本次积分" class="layui-input" value="{$class.integral}">
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">结算账户</label>
                    <div class="layui-input-block">
                        <select id="account" class="layui-input" lay-search>
                            <option value="">请选择结算账户</option>
                		    {volist name="account" id="account_vo"}
                                <option value="{$account_vo.id}">{$account_vo.name}</option>
                            {/volist}
                		</select>
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item" pane>
                    <label class="layui-form-label">组合支付</label>
                    <div class="layui-input-block">
                        <input type="checkbox" id="paycheckbox" lay-skin="switch" lay-text="开|关" lay-filter="paymemu">
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" id="data" placeholder="请输入备注信息" class="layui-input" value="{$class.data}">
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <table class="layui-table" id="pay_menu" style="display:none">
		<thead>
			<tr>
				<th>结算账户</th>
				<th>结算金额</th>
				<th>相关操作<i class="layui-icon ico_add">&#xe61f;</i></th>
			</tr>
		</thead>
		<tbody id="pay_menus">
            <tr>
                <td>
                    <select lay-ignore>
                        {volist name="account" id="account_vo"}
                            <option value="{$account_vo.id}">{$account_vo.name}</option>
                        {/volist}
                    </select>
                </td>
                <td>
                    <input type="text" placeholder="请输入结算金额" oninput="cal_payinfo();"/>
                </td>
                <td>
                    <i class="layui-icon ico_del">&#xe640;</i>
                </td>
            </tr>
		</tbody>
	</table>
</div>
<script type="text/javascript" charset="utf-8">
    var id="{$Think.get.id}";
    var room_zero_stock =  false;
    var warehouse_arr={php}echo warehouse_arr();{/php};
    var tabinfo={php}echo tabinfo('cashier');{/php};
    var roomtabinfo={php}echo tabinfo('cashier_roomlist');{/php};
    var batch_type={empty name="sys.1.info.batch"}false{else/}true{/empty};
    var serial_type={empty name="sys.1.info.serial"}false{else/}true{/empty};
    var account_default='{php}echo $sys[3]['info']['cashier_actual']{/php}';
    $('#pay_menus select').val(account_default);//组合支付默认选项
    var account_arr={php}echo json_encode(db('account')->field('id,name')->select()){/php};
    //赋值
    $('#customer').attr('ape','{$class.customer.ape}').val('{$class.customer.info.name}');
    $('#user').val('{$class.user.ape}');
    {empty name="sys.1.info.user_choose"}$('#user').attr('disabled',true);{/empty}
    //赋值
    $('#account').val('{$class.account.ape}');
    var class_paytype = '{$class.paytype}';
    var class_payinfo = {$class.payinfo};
    var class_type = {$class.type.ape};
    var auto_print={$sys.3.info.cashier_print};
</script>
<script src="/skin/js/public/ztree.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/main/room_info_list.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/public/grid.locale-cn.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/public/select2.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/public/jqGrid.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/main/public_tab.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/main/cashier_tab.js" type="text/javascript" charset="utf-8"></script>
<script src="/skin/js/main/cashierinfo.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    add_goods({php}echo json_encode($info);{/php},false);
    if(class_type!='1'){
        check_tab();//未审核状态检查表格
    }
    if(class_paytype==1){
        $('#paycheckbox').prop("checked",true);
        render_payinfo();
    }
    cal_default_rows();
</script>
{/block}